package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ProduceScheduling;
import com.dragon.repository.entity.SchedulingSon;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProduceSchedulingVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "生产表id")
    private String produceId;

    @ApiModelProperty(value = "生产状态：1生产中2生产完成")
    private Integer type;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "排产子表")
    private List<SchedulingSon> schedulingSonList;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static ProduceScheduling convert(ProduceSchedulingVO vo) {
        ProduceScheduling entity = new ProduceScheduling();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<ProduceScheduling> convertList(List<ProduceSchedulingVO> list) {
        List<ProduceScheduling> resultList = new ArrayList<>();
        for (ProduceSchedulingVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
